package logic

import (
	"context"
	"doc-manager/model/mysql"

	"doc-manager/docrpc/docrpc"
	"doc-manager/docrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DocShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDocShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocShowLogic {
	return &DocShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DocShowLogic) DocShow(in *docrpc.DocShowRequest) (*docrpc.DocShowResponse, error) {
	// todo: add your logic here and delete this line
	var doc mysql.Doc
	err := doc.DocShow(mysql.DB, in.DocId)
	if err != nil {
		return nil, err
	}

	return &docrpc.DocShowResponse{
		Name:  doc.Name,
		Level: doc.Level,
		Types: doc.Types,
	}, nil
}
